package fr.vvins.core.page.entity;

import java.io.Serializable;
import java.util.Map;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.MapKeyJoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import fr.vvins.core.catalog.entity.Content;
import fr.vvins.core.dao.EntityImpl;

@Entity
@Table(schema="www", name="WWW_PAGE")

public class Page extends EntityImpl implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	
	@Basic
	@Column(name="NAME")
	private String name;
	
	@Basic
	@Column(name="DESCRIPTION")
	private String description;
	
	@ManyToOne
	@JoinColumn(name="LAYOUT_ID")
	private Layout layout;

	@ManyToOne
	@JoinColumn(name="CONTENT_ID")
	private Content content;
	
	@OneToMany 
	@JoinTable(schema="www", name="WWW_PG_ZONES", 
		joinColumns=@JoinColumn(name="PAGE_ID"),
		inverseJoinColumns = @JoinColumn( name="BLOCK_ID"))
	@MapKeyJoinColumn(name="ZONE_ID")
	private Map<Zone,Block> blocks;
	

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	public Content getContent() {
		return content;
	}

	public void setContent(Content content) {
		this.content = content;
	}

	public Layout getLayout() {
		return layout;
	}

	public void setLayout(Layout layout) {
		this.layout = layout;
	}

	public Map<Zone, Block> getBlocks() {
		return blocks;
	}

	public void setBlocks(Map<Zone, Block> blocks) {
		this.blocks = blocks;
	}

}
